<?php
include '../config/db_config.php';
include '../lib/kelola_produk.php';
include '../lib/kelola_gambar.php';
include '../lib/kelola_technopreneur.php';

$kelola_produk = new kelola_produk();
$kelola_gambar = new kelola_gambar();
$kelola_technopreneur = new kelola_technopreneur();

if(!isset($_GET['id'])){
	header('location:tampilan_home.php');
}

$id_techno = htmlspecialchars($_GET['id'], ENT_QUOTES);
/*
$result = $kelola_produk->select_produk($id_produk);



$produk;
while ($row = mysql_fetch_assoc($result)) {
	$produk = $row;
	//var_dump($row);
}
*/

/*
$result1 = "SELECT at.ID_TECHNOPRENEUR, p.ID_PRODUK, g.URL, g.DESKRIPSI_GAMBAR FROM gambar as g left join produk as p on g.ID_PRODUK=p.ID_PRODUK left join account_technopreneur as at on at.ID_TECHNOPRENEUR=p.ID_TECHNOPRENEUR WHERE at.ID_TECHNOPRENEUR=1";
$aba=mysql_query($result1)or die("Query failed with error: ".mysql_error());
*/

$result = $kelola_produk->select_produk_by_technopreneur($id_techno);

while ($row = mysql_fetch_assoc($result)) {
	$p['ID_PRODUK'] = $row['ID_PRODUK'];
	$p['NAMA_PRODUK'] = $row['NAMA_PRODUK'];
	
	$result2 = $kelola_gambar->select_gambar($p['ID_PRODUK'], 1);
	while ($row2 = mysql_fetch_assoc($result2)) {
		$p['URL']= $row2['URL'];
		
		
	}
	$produk[] = $p;
}

//	var_dump($produk);

?>

<html>
  <head>
    <title>Smart Commerce</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
	<style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
</head>
<body>
	<?php include "header_guest.php";
	if (@$produk == 0){
		echo 'Tidak ada produk';
		}
	else {
	echo '<ul class="thumbnails">';
		for($i = 0; $i < count($produk); $i++){
		
		 
			echo '<li class="span2">';
			echo '<a href="informasi_produk.php?id='.$produk[$i]['ID_PRODUK'].'" class="thumbnail">';
				if(isset($produk[$i]['URL'])){
					echo '<img src="../'.$produk[$i]['URL'].'" style="width:250px; height:150px" alt="">';
				}
				else{
					echo '<img src="../images/no_image.jpg" style="width:200px; height:100px" alt="">';
				}
				echo "</a>";
				echo '<center><h4>'.$produk[$i]['NAMA_PRODUK'].'</h4></center>';
			echo "</li>";
			
		}
		echo "</ul>";
			  echo "</div>";
		}
		?>
</body>
</html>